home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / SCSI Samples 1.0 / SCSI Async Sample 06⁄15 ƒ / Src / scsi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-16  |  37.2 KB  |  1,004 lines  |  [TEXT/????]

  1. /*
  2.      File:        scsi.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Built by:            Tom Wilson
  8.                  From:                scsi.i
  9.                  With Interfacer:    1.1d4
  10.  
  11.      Bugs:        Report bugs to Radar component “System Interfaces”, “Latest”
  12.                  List the version information from above in Problem Description.
  13.  
  14. */
  15.  
  16. #ifndef __SCSI__
  17. #define __SCSI__
  18.  
  19.  
  20. #ifndef __TYPES__
  21. #include <Types.h>
  22. #endif
  23. /*    #include <ConditionalMacros.h>                                */
  24.  
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28.  
  29. #ifndef _SCSIAtomic
  30.  
  31. enum {
  32.     _SCSIAtomic                    = 0xA089
  33. };
  34.  
  35. #endif
  36.  
  37. enum {
  38.     scInc                        = 1,
  39.     scNoInc                        = 2,
  40.     scAdd                        = 3,
  41.     scMove                        = 4,
  42.     scLoop                        = 5,
  43.     scNop                        = 6,
  44.     scStop                        = 7,
  45.     scComp                        = 8
  46. };
  47.  
  48. /* SCSI Manager errors */
  49.  
  50. enum {
  51.     scCommErr                    = 2,                            /* communications error, operation timeout */
  52.     scArbNBErr                    = 3,                            /* arbitration timeout waiting for not BSY */
  53.     scBadParmsErr                = 4,                            /* bad parameter or TIB opcode */
  54.     scPhaseErr                    = 5,                            /* SCSI bus not in correct phase for attempted operation */
  55.     scCompareErr                = 6,                            /* data compare error */
  56.     scMgrBusyErr                = 7,                            /* SCSI Manager busy  */
  57.     scSequenceErr                = 8,                            /* attempted operation is out of sequence */
  58.     scBusTOErr                    = 9,                            /* CPU bus timeout */
  59.     scComplPhaseErr                = 10                            /* SCSI bus wasn't in Status phase */
  60. };
  61.  
  62. /* Signatures */
  63.  
  64. enum {
  65.     sbSIGWord                    = 0x4552,                        /* signature word for Block 0 ('ER') */
  66.     sbMac                        = 1,                            /* system type for Mac */
  67.     pMapSIG                        = 0x504D,                        /* partition map signature ('PM') */
  68.     pdSigWord                    = 0x5453
  69. };
  70.  
  71. enum {
  72.     oldPMSigWord                = pdSigWord,
  73.     newPMSigWord                = pMapSIG
  74. };
  75.  
  76. /* Driver Descriptor Map */
  77.  
  78. #if defined(powerc) || defined (__powerc)
  79. #pragma options align=mac68k
  80. #endif
  81. struct Block0 {
  82.     unsigned short                    sbSig;                        /* unique value for SCSI block 0 */
  83.     unsigned short                    sbBlkSize;                    /* block size of device */
  84.     unsigned long                    sbBlkCount;                    /* number of blocks on device */
  85.     unsigned short                    sbDevType;                    /* device type */
  86.     unsigned short                    sbDevId;                    /* device id */
  87.     unsigned long                    sbData;                        /* not used */
  88.     unsigned short                    sbDrvrCount;                /* driver descriptor count */
  89.     unsigned long                    ddBlock;                    /* 1st driver's starting block */
  90.     unsigned short                    ddSize;                        /* size of 1st driver (512-byte blks) */
  91.     unsigned short                    ddType;                        /* system type (1 for Mac+) */
  92.     unsigned short                    ddPad[243];                    /* ARRAY[0..242] OF INTEGER; not used */
  93. };
  94. #if defined(powerc) || defined(__powerc)
  95. #pragma options align=reset
  96. #endif
  97.  
  98. typedef struct Block0 Block0;
  99.  
  100. /* Partition Map Entry */
  101.  
  102. #if defined(powerc) || defined (__powerc)
  103. #pragma options align=mac68k
  104. #endif
  105. struct Partition {
  106.     unsigned short                    pmSig;                        /* unique value for map entry blk */
  107.     unsigned short                    pmSigPad;                    /* currently unused */
  108.     unsigned long                    pmMapBlkCnt;                /* # of blks in partition map */
  109.     unsigned long                    pmPyPartStart;                /* physical start blk of partition */
  110.     unsigned long                    pmPartBlkCnt;                /* # of blks in this partition */
  111.     unsigned char                    pmPartName[32];                /* ASCII partition name */
  112.     unsigned char                    pmParType[32];                /* ASCII partition type */
  113.     unsigned long                    pmLgDataStart;                /* log. # of partition's 1st data blk */
  114.     unsigned long                    pmDataCnt;                    /* # of blks in partition's data area */
  115.     unsigned long                    pmPartStatus;                /* bit field for partition status */
  116.     unsigned long                    pmLgBootStart;                /* log. blk of partition's boot code */
  117.     unsigned long                    pmBootSize;                    /* number of bytes in boot code */
  118.     unsigned long                    pmBootAddr;                    /* memory load address of boot code */
  119.     unsigned long                    pmBootAddr2;                /* currently unused */
  120.     unsigned long                    pmBootEntry;                /* entry point of boot code */
  121.     unsigned long                    pmBootEntry2;                /* currently unused */
  122.     unsigned long                    pmBootCksum;                /* checksum of boot code */
  123.     unsigned char                    pmProcessor[16];            /* ASCII for the processor type */
  124.     unsigned short                    pmPad[188];                    /* 512 bytes long currently unused */
  125. };
  126. #if defined(powerc) || defined(__powerc)
  127. #pragma options align=reset
  128. #endif
  129.  
  130. typedef struct Partition Partition;
  131.  
  132. /* TIB instruction */
  133.  
  134. #if defined(powerc) || defined (__powerc)
  135. #pragma options align=mac68k
  136. #endif
  137. struct SCSIInstr {
  138.     unsigned short                    scOpcode;
  139.     unsigned long                    scParam1;
  140.     unsigned long                    scParam2;
  141. };
  142. #if defined(powerc) || defined(__powerc)
  143. #pragma options align=reset
  144. #endif
  145.  
  146. typedef struct SCSIInstr SCSIInstr;
  147.  
  148. extern pascal OSErr SCSIReset(void)
  149.  TWOWORDINLINE(0x4267, 0xA815);
  150. extern pascal OSErr SCSIGet(void)
  151.  THREEWORDINLINE(0x3F3C, 0x0001, 0xA815);
  152. extern pascal OSErr SCSISelect(short targetID)
  153.  THREEWORDINLINE(0x3F3C, 0x0002, 0xA815);
  154. extern pascal OSErr SCSICmd(Ptr buffer, short count)
  155.  THREEWORDINLINE(0x3F3C, 0x0003, 0xA815);
  156. extern pascal OSErr SCSIRead(Ptr tibPtr)
  157.  THREEWORDINLINE(0x3F3C, 0x0005, 0xA815);
  158. extern pascal OSErr SCSIRBlind(Ptr tibPtr)
  159.  THREEWORDINLINE(0x3F3C, 0x0008, 0xA815);
  160. extern pascal OSErr SCSIWrite(Ptr tibPtr)
  161.  THREEWORDINLINE(0x3F3C, 0x0006, 0xA815);
  162. extern pascal OSErr SCSIWBlind(Ptr tibPtr)
  163.  THREEWORDINLINE(0x3F3C, 0x0009, 0xA815);
  164. extern pascal OSErr SCSIComplete(short *stat, short *message, unsigned long wait)
  165.  THREEWORDINLINE(0x3F3C, 0x0004, 0xA815);
  166. extern pascal short SCSIStat(void)
  167.  THREEWORDINLINE(0x3F3C, 0x000A, 0xA815);
  168. extern pascal OSErr SCSISelAtn(short targetID)
  169.  THREEWORDINLINE(0x3F3C, 0x000B, 0xA815);
  170. extern pascal OSErr SCSIMsgIn(short *message)
  171.  THREEWORDINLINE(0x3F3C, 0x000C, 0xA815);
  172. extern pascal OSErr SCSIMsgOut(short message)
  173.  THREEWORDINLINE(0x3F3C, 0x000D, 0xA815);
  174. /*——————————————————————— New SCSI Manager Interface ———————————————————————*/
  175.  
  176.  
  177. enum {
  178.     scsiVERSION                    = 43
  179. };
  180.  
  181. /* SCSI Manager function codes */
  182.  
  183. enum {
  184.     SCSINop                        = 0x00,                            /* Execute nothing                                         */
  185.     SCSIExecIO                    = 0x01,                            /* Execute the specified IO                             */
  186.     SCSIBusInquiry                = 0x03,                            /* Get parameters for entire path of HBAs                 */
  187.     SCSIReleaseQ                = 0x04,                            /* Release the frozen SIM queue for particular LUN         */
  188.     SCSIAbortCommand            = 0x10,                            /* Abort the selected Control Block                      */
  189.     SCSIResetBus                = 0x11,                            /* Reset the SCSI bus                                      */
  190.     SCSIResetDevice                = 0x12,                            /* Reset the SCSI device                                  */
  191.     SCSITerminateIO                = 0x13,                            /* Terminate any pending IO                              */
  192.     SCSIGetVirtualIDInfo        = 0x80,                            /* Find out which bus old ID is on                         */
  193.     SCSILoadDriver                = 0x82,                            /* Load a driver for a device ident                     */
  194.     SCSIOldCall                    = 0x84,                            /* XPT->SIM private call for old-API                     */
  195.     SCSICreateRefNumXref        = 0x85,                            /* Register a DeviceIdent to drvr RefNum xref             */
  196.     SCSILookupRefNumXref        = 0x86,                            /* Get DeviceIdent to drvr RefNum xref                     */
  197.     SCSIRemoveRefNumXref        = 0x87,                            /* Remove a DeviceIdent to drvr RefNum xref             */
  198.     SCSIRegisterWithNewXPT        = 0x88,                            /* XPT has changed - SIM needs to re-register itself     */
  199.     vendorUnique                = 0xC0                            /* 0xC0 thru 0xFF */
  200. };
  201.  
  202. /* SCSI Callback Procedure Prototypes */
  203.  
  204. typedef pascal void (*CallbackProc)(void *scsiPB);
  205. typedef void (*AENCallbackProc)(void);
  206. typedef OSErr (*SIMInitProc)(Ptr SIMinfoPtr);
  207. typedef void (*SIMActionProc)(void *scsiPB, Ptr SIMGlobals);
  208. typedef void (*SCSIProc)(void);
  209. typedef void (*MakeCallbackProc)(void *scsiPB);
  210. typedef long (*InterruptPollProc)(Ptr SIMGlobals);
  211. /* Allocation length defines for some of the fields */
  212.  
  213.  
  214. enum {
  215.     handshakeDataLength            = 8,                            /* Handshake data length */
  216.     maxCDBLength                = 16,                            /* Space for the CDB bytes/pointer */
  217.     vendorIDLength                = 16                            /* ASCII string len for Vendor ID  */
  218. };
  219.  
  220. /* Define DeviceIdent structure */
  221.  
  222. #if defined(powerc) || defined (__powerc)
  223. #pragma options align=mac68k
  224. #endif
  225. struct DeviceIdent {
  226.     unsigned char                            diReserved;                    /* reserved                 */
  227.     unsigned char                            bus;                        /* SCSI - Bus Number        */
  228.     unsigned char                            targetID;                    /* SCSI - Target SCSI ID    */
  229.     unsigned char                            LUN;                        /* SCSI - LUN                  */
  230. };
  231. #if defined(powerc) || defined(__powerc)
  232. #pragma options align=reset
  233. #endif
  234.  
  235. typedef struct DeviceIdent DeviceIdent;
  236.  
  237. /* Command Descriptor Block structure */
  238.  
  239. union CDB {
  240.     unsigned char                            *cdbPtr;                    /* ptr to the CDB bytes to send, or… */
  241.     unsigned char                            cdbBytes[maxCDBLength];        /* actual CDB to send */
  242. };
  243. #if 0    //** MM
  244. typedef CDB CDB, *CDBPtr;
  245. #else
  246. typedef union CDB CDB, *CDBPtr;
  247. #endif
  248.  
  249. /* Scatter/gather list element */
  250.  
  251. #if defined(powerc) || defined (__powerc)
  252. #pragma options align=mac68k
  253. #endif
  254. struct SGRecord {
  255.     Ptr                                SGAddr;
  256.     unsigned long                            SGCount;
  257. };
  258. #if defined(powerc) || defined(__powerc)
  259. #pragma options align=reset
  260. #endif
  261.  
  262. typedef struct SGRecord SGRecord;
  263.  
  264. /* SCSI Phases (used by SIMs to support the Original SCSI Manager */
  265.  
  266.  
  267. enum {
  268.     kDataOutPhase,                                                /* Encoded MSG, C/D, I/O bits */
  269.     kDataInPhase,
  270.     kCommandPhase,
  271.     kStatusPhase,
  272.     kPhaseIllegal0,
  273.     kPhaseIllegal1,
  274.     kMessageOutPhase,
  275.     kMessageInPhase,
  276.     kBusFreePhase,                                                /* Additional Phases */
  277.     kArbitratePhase,
  278.     kSelectPhase,
  279.     kMessageInPhaseNACK                                            /* Message In Phase with ACK hanging on the bus */
  280. };
  281.  
  282. #if defined(powerc) || defined (__powerc)
  283. #pragma options align=mac68k
  284. #endif
  285. struct SCSIHdr {
  286.     struct SCSIHdr                    *qLink;
  287.     short                            scsiReserved1;
  288.     unsigned short                            scsiPBLength;
  289.     unsigned char                            scsiFunctionCode;
  290.     unsigned char                            scsiReserved2;
  291.     OSErr                            scsiResult;
  292.     DeviceIdent                        scsiDevice;
  293.     CallbackProc                    scsiCompletion;
  294.     unsigned long                            scsiFlags;
  295.     unsigned char                            *scsiDriverStorage;
  296.     Ptr                                scsiXPTprivate;
  297.     long                            scsiReserved3;
  298. };
  299. #if defined(powerc) || defined(__powerc)
  300. #pragma options align=reset
  301. #endif
  302.  
  303. typedef struct SCSIHdr SCSIHdr;
  304.  
  305. #if defined(powerc) || defined (__powerc)
  306. #pragma options align=mac68k
  307. #endif
  308. struct SCSI_PB {
  309.     struct SCSIHdr                    *qLink;
  310.     short                            scsiReserved1;
  311.     unsigned short                            scsiPBLength;
  312.     unsigned char                            scsiFunctionCode;
  313.     unsigned char                            scsiReserved2;
  314.     OSErr                            scsiResult;
  315.     DeviceIdent                        scsiDevice;
  316.     CallbackProc                    scsiCompletion;
  317.     unsigned long                            scsiFlags;
  318.     unsigned char                            *scsiDriverStorage;
  319.     Ptr                                scsiXPTprivate;
  320.     long                            scsiReserved3;
  321. };
  322. #if defined(powerc) || defined(__powerc)
  323. #pragma options align=reset
  324. #endif
  325.  
  326. typedef struct SCSI_PB SCSI_PB;
  327.  
  328. #if defined(powerc) || defined (__powerc)
  329. #pragma options align=mac68k
  330. #endif
  331. struct SCSI_IO {
  332.     struct SCSIHdr                    *qLink;
  333.     short                            scsiReserved1;
  334.     unsigned short                            scsiPBLength;
  335.     unsigned char                            scsiFunctionCode;
  336.     unsigned char                            scsiReserved2;
  337.     OSErr                            scsiResult;
  338.     DeviceIdent                        scsiDevice;
  339.     CallbackProc                    scsiCompletion;
  340.     unsigned long                            scsiFlags;
  341.     unsigned char                            *scsiDriverStorage;
  342.     Ptr                                scsiXPTprivate;
  343.     long                            scsiReserved3;
  344.     unsigned short                            scsiResultFlags;
  345.     unsigned short                            scsiReserved3pt5;
  346.     unsigned char                            *scsiDataPtr;
  347.     unsigned long                            scsiDataLength;
  348.     unsigned char                            *scsiSensePtr;
  349.     unsigned char                            scsiSenseLength;
  350.     unsigned char                            scsiCDBLength;
  351.     unsigned short                            scsiSGListCount;
  352.     unsigned long                            scsiReserved4;
  353.     unsigned char                            scsiSCSIstatus;
  354.     char                            scsiSenseResidual;
  355.     unsigned short                            scsiReserved5;
  356.     long                            scsiDataResidual;
  357.     CDB                                scsiCDB;
  358.     long                            scsiTimeout;
  359.     unsigned char                            *scsiReserved5pt5;
  360.     unsigned short                            scsiReserved5pt6;
  361.     unsigned short                            scsiIOFlags;
  362.     unsigned char                            scsiTagAction;
  363.     unsigned char                            scsiReserved6;
  364.     unsigned short                            scsiReserved7;
  365.     unsigned short                            scsiSelectTimeout;
  366.     unsigned char                            scsiDataType;
  367.     unsigned char                            scsiTransferType;
  368.     unsigned long                            scsiReserved8;
  369.     unsigned long                            scsiReserved9;
  370.     unsigned short                            scsiHandshake[handshakeDataLength];
  371.     unsigned long                            scsiReserved10;
  372.     unsigned long                            scsiReserved11;
  373.     struct SCSI_IO                    *scsiCommandLink;
  374.     unsigned char                            scsiSIMpublics[8];
  375.     unsigned char                            scsiAppleReserved6[8];
  376.     unsigned short                            scsiCurrentPhase;
  377.     short                            scsiSelector;
  378.     OSErr                            scsiOldCallResult;
  379.     unsigned char                            scsiSCSImessage;
  380.     unsigned char                            XPTprivateFlags;
  381.     unsigned char                            XPTextras[12];
  382. };
  383. #if defined(powerc) || defined(__powerc)
  384. #pragma options align=reset
  385. #endif
  386.  
  387. typedef struct SCSI_IO SCSI_IO;
  388.  
  389. typedef SCSI_IO SCSIExecIOPB;
  390.  
  391. /* Bus inquiry PB */
  392.  
  393. #if defined(powerc) || defined (__powerc)
  394. #pragma options align=mac68k
  395. #endif
  396. struct SCSIBusInquiryPB {
  397.     struct SCSIHdr                    *qLink;
  398.     short                            scsiReserved1;
  399.     unsigned short                            scsiPBLength;
  400.     unsigned char                            scsiFunctionCode;
  401.     unsigned char                            scsiReserved2;
  402.     OSErr                            scsiResult;
  403.     DeviceIdent                        scsiDevice;
  404.     CallbackProc                    scsiCompletion;
  405.     unsigned long                            scsiFlags;
  406.     unsigned char                            *scsiDriverStorage;
  407.     Ptr                                scsiXPTprivate;
  408.     long                            scsiReserved3;
  409.     unsigned short                            scsiEngineCount;            /* <- Number of engines on HBA                         */
  410.     unsigned short                            scsiMaxTransferType;        /* <- Number of transfer types for this HBA            */
  411.     unsigned long                            scsiDataTypes;                /* <- which data types are supported by this SIM     */
  412.     unsigned short                            scsiIOpbSize;                /* <- Size of SCSI_IO PB for this SIM/HBA             */
  413.     unsigned short                            scsiMaxIOpbSize;            /* <- Size of max SCSI_IO PB for all SIM/HBAs         */
  414.     unsigned long                            scsiFeatureFlags;            /* <- Supported features flags field                 */
  415.     unsigned char                            scsiVersionNumber;            /* <- Version number for the SIM/HBA                 */
  416.     unsigned char                            scsiHBAInquiry;                /* <- Mimic of INQ byte 7 for the HBA                 */
  417.     unsigned char                            scsiTargetModeFlags;        /* <- Flags for target mode support                 */
  418.     unsigned char                            scsiScanFlags;                /* <- Scan related feature flags                     */
  419.     unsigned long                            scsiSIMPrivatesPtr;            /* <- Ptr to SIM private data area                     */
  420.     unsigned long                            scsiSIMPrivatesSize;        /* <- Size of SIM private data area                 */
  421.     unsigned long                            scsiAsyncFlags;                /* <- Event cap. for Async Callback                 */
  422.     unsigned char                            scsiHiBusID;                /* <- Highest path ID in the subsystem              */
  423.     unsigned char                            scsiInitiatorID;            /* <- ID of the HBA on the SCSI bus                 */
  424.     unsigned short                            scsiBIReserved0;            /*                                                    */
  425.     unsigned long                            scsiBIReserved1;            /* <-                                                  */
  426.     unsigned long                            scsiFlagsSupported;            /* <- which scsiFlags are supported                 */
  427.     unsigned short                            scsiIOFlagsSupported;        /* <- which scsiIOFlags are supported                 */
  428.     unsigned short                            scsiWeirdStuff;                /* <-                                                 */
  429.     unsigned short                            scsiMaxTarget;                /* <- maximum Target number supported                 */
  430.     unsigned short                            scsiMaxLUN;                    /* <- maximum Logical Unit number supported         */
  431.     char                            scsiSIMVendor[vendorIDLength]; /* <- Vendor ID of SIM (or XPT if bus<FF)         */
  432.     char                            scsiHBAVendor[vendorIDLength]; /* <- Vendor ID of the HBA                         */
  433.     char                            scsiControllerFamily[vendorIDLength]; /* <- Family of SCSI Controller                 */
  434.     char                            scsiControllerType[vendorIDLength]; /* <- Specific Model of SCSI Controller used     */
  435.     char                            scsiXPTversion[4];            /* <- version number of XPT                         */
  436.     char                            scsiSIMversion[4];            /* <- version number of SIM                         */
  437.     char                            scsiHBAversion[4];            /* <- version number of HBA                         */
  438.     unsigned char                            scsiHBAslotType;            /* <- type of "slot" that this HBA is in            */
  439.     unsigned char                            scsiHBAslotNumber;            /* <- slot number of this HBA                         */
  440.     unsigned short                            scsiSIMsRsrcID;                /* <- resource ID of this SIM                         */
  441.     unsigned short                            scsiBIReserved3;            /* <-                                                 */
  442.     unsigned short                            scsiAdditionalLength;        /* <- additional BusInquiry PB len                    */
  443. };
  444. #if defined(powerc) || defined(__powerc)
  445. #pragma options align=reset
  446. #endif
  447.  
  448. typedef struct SCSIBusInquiryPB SCSIBusInquiryPB;
  449.  
  450. /* Abort SIM Request PB */
  451.  
  452. #if defined(powerc) || defined (__powerc)
  453. #pragma options align=mac68k
  454. #endif
  455. struct SCSIAbortCommandPB {
  456.     struct SCSIHdr                    *qLink;
  457.     short                            scsiReserved1;
  458.     unsigned short                            scsiPBLength;
  459.     unsigned char                            scsiFunctionCode;
  460.     unsigned char                            scsiReserved2;
  461.     OSErr                            scsiResult;
  462.     DeviceIdent                        scsiDevice;
  463.     CallbackProc                    scsiCompletion;
  464.     unsigned long                            scsiFlags;
  465.     unsigned char                            *scsiDriverStorage;
  466.     Ptr                                scsiXPTprivate;
  467.     long                            scsiReserved3;
  468.     SCSI_IO                            *scsiIOptr;                    /* Pointer to the PB to abort                        */
  469. };
  470. #if defined(powerc) || defined(__powerc)
  471. #pragma options align=reset
  472. #endif
  473.  
  474. typedef struct SCSIAbortCommandPB SCSIAbortCommandPB;
  475.  
  476. /* Terminate I/O Process Request PB */
  477.  
  478. #if defined(powerc) || defined (__powerc)
  479. #pragma options align=mac68k
  480. #endif
  481. struct SCSITerminateIOPB {
  482.     struct SCSIHdr                    *qLink;
  483.     short                            scsiReserved1;
  484.     unsigned short                            scsiPBLength;
  485.     unsigned char                            scsiFunctionCode;
  486.     unsigned char                            scsiReserved2;
  487.     OSErr                            scsiResult;
  488.     DeviceIdent                        scsiDevice;
  489.     CallbackProc                    scsiCompletion;
  490.     unsigned long                            scsiFlags;
  491.     unsigned char                            *scsiDriverStorage;
  492.     Ptr                                scsiXPTprivate;
  493.     long                            scsiReserved3;
  494.     SCSI_IO                            *scsiIOptr;                    /* Pointer to the PB to terminate                     */
  495. };
  496. #if defined(powerc) || defined(__powerc)
  497. #pragma options align=reset
  498. #endif
  499.  
  500. typedef struct SCSITerminateIOPB SCSITerminateIOPB;
  501.  
  502. /* Reset SCSI Bus PB */
  503.  
  504. #if defined(powerc) || defined (__powerc)
  505. #pragma options align=mac68k
  506. #endif
  507. struct SCSIResetBusPB {
  508.     struct SCSIHdr                    *qLink;
  509.     short                            scsiReserved1;
  510.     unsigned short                            scsiPBLength;
  511.     unsigned char                            scsiFunctionCode;
  512.     unsigned char                            scsiReserved2;
  513.     OSErr                            scsiResult;
  514.     DeviceIdent                        scsiDevice;
  515.     CallbackProc                    scsiCompletion;
  516.     unsigned long                            scsiFlags;
  517.     unsigned char                            *scsiDriverStorage;
  518.     Ptr                                scsiXPTprivate;
  519.     long                            scsiReserved3;
  520. };
  521. #if defined(powerc) || defined(__powerc)
  522. #pragma options align=reset
  523. #endif
  524.  
  525. typedef struct SCSIResetBusPB SCSIResetBusPB;
  526.  
  527. /* Reset SCSI Device PB */
  528.  
  529. #if defined(powerc) || defined (__powerc)
  530. #pragma options align=mac68k
  531. #endif
  532. struct SCSIResetDevicePB {
  533.     struct SCSIHdr                    *qLink;
  534.     short                            scsiReserved1;
  535.     unsigned short                            scsiPBLength;
  536.     unsigned char                            scsiFunctionCode;
  537.     unsigned char                            scsiReserved2;
  538.     OSErr                            scsiResult;
  539.     DeviceIdent                        scsiDevice;
  540.     CallbackProc                    scsiCompletion;
  541.     unsigned long                            scsiFlags;
  542.     unsigned char                            *scsiDriverStorage;
  543.     Ptr                                scsiXPTprivate;
  544.     long                            scsiReserved3;
  545. };
  546. #if defined(powerc) || defined(__powerc)
  547. #pragma options align=reset
  548. #endif
  549.  
  550. typedef struct SCSIResetDevicePB SCSIResetDevicePB;
  551.  
  552. /* Release SIM Queue PB */
  553.  
  554. #if defined(powerc) || defined (__powerc)
  555. #pragma options align=mac68k
  556. #endif
  557. struct SCSIReleaseQPB {
  558.     struct SCSIHdr                    *qLink;
  559.     short                            scsiReserved1;
  560.     unsigned short                            scsiPBLength;
  561.     unsigned char                            scsiFunctionCode;
  562.     unsigned char                            scsiReserved2;
  563.     OSErr                            scsiResult;
  564.     DeviceIdent                        scsiDevice;
  565.     CallbackProc                    scsiCompletion;
  566.     unsigned long                            scsiFlags;
  567.     unsigned char                            *scsiDriverStorage;
  568.     Ptr                                scsiXPTprivate;
  569.     long                            scsiReserved3;
  570. };
  571. #if defined(powerc) || defined(__powerc)
  572. #pragma options align=reset
  573. #endif
  574.  
  575. typedef struct SCSIReleaseQPB SCSIReleaseQPB;
  576.  
  577. /* SCSI Get Virtual ID Info PB */
  578.  
  579. #if defined(powerc) || defined (__powerc)
  580. #pragma options align=mac68k
  581. #endif
  582. struct SCSIGetVirtualIDInfoPB {
  583.     struct SCSIHdr                    *qLink;
  584.     short                            scsiReserved1;
  585.     unsigned short                            scsiPBLength;
  586.     unsigned char                            scsiFunctionCode;
  587.     unsigned char                            scsiReserved2;
  588.     OSErr                            scsiResult;
  589.     DeviceIdent                        scsiDevice;
  590.     CallbackProc                    scsiCompletion;
  591.     unsigned long                            scsiFlags;
  592.     unsigned char                            *scsiDriverStorage;
  593.     Ptr                                scsiXPTprivate;
  594.     long                            scsiReserved3;
  595.     unsigned short                            scsiOldCallID;                /* -> SCSI ID of device in question             */
  596.     Boolean                            scsiExists;                    /* <- true if device exists                     */
  597. };
  598. #if defined(powerc) || defined(__powerc)
  599. #pragma options align=reset
  600. #endif
  601.  
  602. typedef struct SCSIGetVirtualIDInfoPB SCSIGetVirtualIDInfoPB;
  603.  
  604. /* Create/Lookup/Remove RefNum for Device PB */
  605.  
  606. #if defined(powerc) || defined (__powerc)
  607. #pragma options align=mac68k
  608. #endif
  609. struct SCSIDriverPB {
  610.     struct SCSIHdr                    *qLink;
  611.     short                            scsiReserved1;
  612.     unsigned short                            scsiPBLength;
  613.     unsigned char                            scsiFunctionCode;
  614.     unsigned char                            scsiReserved2;
  615.     OSErr                            scsiResult;
  616.     DeviceIdent                        scsiDevice;
  617.     CallbackProc                    scsiCompletion;
  618.     unsigned long                            scsiFlags;
  619.     unsigned char                            *scsiDriverStorage;
  620.     Ptr                                scsiXPTprivate;
  621.     long                            scsiReserved3;
  622.     short                            scsiDriver;                    /* -> DriverRefNum, For SetDriver, <- For GetNextDriver */
  623.     unsigned short                            scsiDriverFlags;            /* <> Details of driver/device                     */
  624.     DeviceIdent                        scsiNextDevice;                /* <- DeviceIdent of the NEXT Item in the list  */
  625. };
  626. #if defined(powerc) || defined(__powerc)
  627. #pragma options align=reset
  628. #endif
  629.  
  630. typedef struct SCSIDriverPB SCSIDriverPB;
  631.  
  632. /* Load Driver PB */
  633.  
  634. #if defined(powerc) || defined (__powerc)
  635. #pragma options align=mac68k
  636. #endif
  637. struct SCSILoadDriverPB {
  638.     struct SCSIHdr                    *qLink;
  639.     short                            scsiReserved1;
  640.     unsigned short                            scsiPBLength;
  641.     unsigned char                            scsiFunctionCode;
  642.     unsigned char                            scsiReserved2;
  643.     OSErr                            scsiResult;
  644.     DeviceIdent                        scsiDevice;
  645.     CallbackProc                    scsiCompletion;
  646.     unsigned long                            scsiFlags;
  647.     unsigned char                            *scsiDriverStorage;
  648.     Ptr                                scsiXPTprivate;
  649.     long                            scsiReserved3;
  650.     short                            scsiLoadedRefNum;            /* <- SIM returns refnum of driver                     */
  651.     Boolean                            scsiDiskLoadFailed;            /* -> if true, indicates call after failure to load */
  652. };
  653. #if defined(powerc) || defined(__powerc)
  654. #pragma options align=reset
  655. #endif
  656.  
  657. typedef struct SCSILoadDriverPB SCSILoadDriverPB;
  658.  
  659. /* Defines for the scsiTransferType field */
  660.  
  661.  
  662. enum {
  663.     scsiTransferBlind            = 0,
  664.     scsiTransferPolled
  665. };
  666.  
  667. /* Defines for the scsiDataType field */
  668.  
  669. enum {
  670.     scsiDataBuffer                = 0,                            /* single contiguous buffer supplied                  */
  671.     scsiDataTIB                    = 1,                            /* TIB supplied (ptr in scsiDataPtr)                 */
  672.     scsiDataSG                    = 2                                /* scatter/gather list supplied                      */
  673. };
  674.  
  675. /* Defines for the SCSIMgr scsiResult field in the PB header. */
  676.  
  677. /*  $E100 thru  E1FF */
  678.  
  679. /* -$1EFF thru -1E00 */
  680.  
  681. /* -#7935 thru -7681  */
  682.  
  683. /* = 0xE100 */
  684.  
  685. enum {
  686.     scsiErrorBase                = -7936
  687. };
  688.  
  689. enum {
  690.     scsiRequestInProgress        = 1,                            /* 1     = PB request is in progress             */
  691. /* Execution failed  00-2F */
  692.     scsiRequestAborted            = scsiErrorBase + 2,            /* -7934 = PB request aborted by the host         */
  693.     scsiUnableToAbort            = scsiErrorBase + 3,            /* -7933 = Unable to Abort PB request             */
  694.     scsiNonZeroStatus            = scsiErrorBase + 4,            /* -7932 = PB request completed with an err     */
  695.     scsiUnused05                = scsiErrorBase + 5,            /* -7931 =                                      */
  696.     scsiUnused06                = scsiErrorBase + 6,            /* -7930 =                                      */
  697.     scsiUnused07                = scsiErrorBase + 7,            /* -7929 =                                      */
  698.     scsiUnused08                = scsiErrorBase + 8,            /* -7928 =                                      */
  699.     scsiUnableToTerminate        = scsiErrorBase + 9,            /* -7927 = Unable to Terminate I/O PB req         */
  700.     scsiSelectTimeout            = scsiErrorBase + 10,            /* -7926 = Target selection timeout             */
  701.     scsiCommandTimeout            = scsiErrorBase + 11,            /* -7925 = Command timeout                      */
  702.     scsiIdentifyMessageRejected    = scsiErrorBase + 12,            /* -7924 =                                      */
  703.     scsiMessageRejectReceived    = scsiErrorBase + 13,            /* -7923 = Message reject received                 */
  704.     scsiSCSIBusReset            = scsiErrorBase + 14,            /* -7922 = SCSI bus reset sent/received         */
  705.     scsiParityError                = scsiErrorBase + 15,            /* -7921 = Uncorrectable parity error occured     */
  706.     scsiAutosenseFailed            = scsiErrorBase + 16,            /* -7920 = Autosense: Request sense cmd fail     */
  707.     scsiUnused11                = scsiErrorBase + 17,            /* -7919 =                                      */
  708.     scsiDataRunError            = scsiErrorBase + 18,            /* -7918 = Data overrun/underrun error          */
  709.     scsiUnexpectedBusFree        = scsiErrorBase + 19,            /* -7917 = Unexpected BUS free                     */
  710.     scsiSequenceFailed            = scsiErrorBase + 20,            /* -7916 = Target bus phase sequence failure     */
  711.     scsiWrongDirection            = scsiErrorBase + 21,            /* -7915 = Data phase was in wrong direction     */
  712.     scsiUnused16                = scsiErrorBase + 22,            /* -7914 =                                      */
  713.     scsiBDRsent                    = scsiErrorBase + 23,            /* -7913 = A SCSI BDR msg was sent to target     */
  714.     scsiTerminated                = scsiErrorBase + 24,            /* -7912 = PB request terminated by the host     */
  715.     scsiNoNexus                    = scsiErrorBase + 25,            /* -7911 = Nexus is not established             */
  716.     scsiCDBReceived                = scsiErrorBase + 26,            /* -7910 = The SCSI CDB has been received         */
  717. /* Couldn't begin execution  30-3F */
  718.     scsiTooManyBuses            = scsiErrorBase + 48,            /* -7888 = Register failed because we're full    */
  719.     scsiBusy                    = scsiErrorBase + 49,            /* -7887 = SCSI subsystem is busy                 */
  720.     scsiProvideFail                = scsiErrorBase + 50,            /* -7886 = Unable to provide requ. capability    */
  721.     scsiDeviceNotThere            = scsiErrorBase + 51,            /* -7885 = SCSI device not installed/there      */
  722.     scsiNoHBA                    = scsiErrorBase + 52,            /* -7884 = No HBA detected Error                 */
  723.     scsiDeviceConflict            = scsiErrorBase + 53,            /* -7883 = sorry, max 1 refNum per DeviceIdent     */
  724.     scsiNoSuchXref                = scsiErrorBase + 54,            /* -7882 = no such RefNum xref                     */
  725.     scsiQLinkInvalid            = scsiErrorBase + 55,            /* -7881 = pre-linked PBs not supported            
  726.                                                                    (The QLink field was nonzero)        */
  727. /* Parameter errors  40-7F */
  728.     scsiPBLengthError            = scsiErrorBase + 64,            /* -7872 = (scsiPBLength is insuf'ct/invalid     */
  729.     scsiFunctionNotAvailable    = scsiErrorBase + 65,            /* -7871 = The requ. func is not available      */
  730.     scsiRequestInvalid            = scsiErrorBase + 66,            /* -7870 = PB request is invalid                 */
  731.     scsiBusInvalid                = scsiErrorBase + 67,            /* -7869 = Bus ID supplied is invalid              */
  732.     scsiTIDInvalid                = scsiErrorBase + 68,            /* -7868 = Target ID supplied is invalid         */
  733.     scsiLUNInvalid                = scsiErrorBase + 69,            /* -7867 = LUN supplied is invalid              */
  734.     scsiIDInvalid                = scsiErrorBase + 70,            /* -7866 = The initiator ID is invalid          */
  735.     scsiDataTypeInvalid            = scsiErrorBase + 71,            /* -7865 = scsiDataType requested not supported */
  736.     scsiTransferTypeInvalid        = scsiErrorBase + 72,            /* -7864 = scsiTransferType field is too high     */
  737.     scsiCDBLengthInvalid        = scsiErrorBase + 73            /* -7863 = scsiCDBLength field is too big         */
  738. };
  739.  
  740. enum {
  741.     scsiExecutionErrors            = scsiErrorBase,
  742.     scsiNotExecutedErrors        = scsiTooManyBuses,
  743.     scsiParameterErrors            = scsiPBLengthError
  744. };
  745.  
  746. /* Defines for the scsiResultFlags field */
  747.  
  748. enum {
  749.     scsiSIMQFrozen                = 0x0001,                        /* The SIM queue is frozen w/this err            */
  750.     scsiAutosenseValid            = 0x0002,                        /* Autosense data valid for target              */
  751.     scsiBusNotFree                = 0x0004                        /* At time of callback, SCSI bus is not free    */
  752. };
  753.  
  754. /* Defines for the bit numbers of the scsiFlags field in the PB header for the SCSIExecIO function */
  755.  
  756. enum {
  757.     kbSCSIDisableAutosense        = 29,                            /* Disable auto sense feature                     */
  758.     kbSCSIFlagReservedA            = 28,                            /*                                              */
  759.     kbSCSIFlagReserved0            = 27,                            /*                                              */
  760.     kbSCSICDBLinked                = 26,                            /* The PB contains a linked CDB                    */
  761.     kbSCSIQEnable                = 25,                            /* Target queue actions are enabled                */
  762.     kbSCSICDBIsPointer            = 24,                            /* The CDB field contains a pointer                */
  763.     kbSCSIFlagReserved1            = 23,                            /*                                                 */
  764.     kbSCSIInitiateSyncData        = 22,                            /* Attempt Sync data xfer and SDTR                */
  765.     kbSCSIDisableSyncData        = 21,                            /* Disable sync, go to async                    */
  766.     kbSCSISIMQHead                = 20,                            /* Place PB at the head of SIM Q                */
  767.     kbSCSISIMQFreeze            = 19,                            /* Return the SIM Q to frozen state                */
  768.     kbSCSISIMQNoFreeze            = 18,                            /* Disallow SIM Q freezing                        */
  769.     kbSCSIDoDisconnect            = 17,                            /* Definitely do disconnect                        */
  770.     kbSCSIDontDisconnect        = 16,                            /* Definitely don't disconnect                    */
  771.     kbSCSIDataReadyForDMA        = 15,                            /* Data buffer(s) are ready for DMA                */
  772.     kbSCSIFlagReserved3            = 14,                            /*                                                 */
  773.     kbSCSIDataPhysical            = 13,                            /* SG/Buffer data ptrs are physical                */
  774.     kbSCSISensePhysical            = 12,                            /* Autosense buffer ptr is physical                */
  775.     kbSCSIFlagReserved5            = 11,                            /*                                                 */
  776.     kbSCSIFlagReserved6            = 10,                            /*                                                 */
  777.     kbSCSIFlagReserved7            = 9,                            /*                                                 */
  778.     kbSCSIFlagReserved8            = 8,                            /*                                                 */
  779.     kbSCSIDataBufferValid        = 7,                            /* Data buffer valid                            */
  780.     kbSCSIStatusBufferValid        = 6,                            /* Status buffer valid                             */
  781.     kbSCSIMessageBufferValid    = 5,                            /* Message buffer valid                            */
  782.     kbSCSIFlagReserved9            = 4                                /*                                              */
  783. };
  784.  
  785. /* Defines for the bit masks of the scsiFlags field */
  786.  
  787. enum {
  788.     scsiDirectionMask            = 0xC0000000,                    /* Data direction mask                        */
  789.     scsiDirectionNone            = 0xC0000000,                    /* Data direction (11: no data)                */
  790.     scsiDirectionReserved        = 0x00000000,                    /* Data direction (00: reserved)            */
  791.     scsiDirectionOut            = 0x80000000,                    /* Data direction (10: DATA OUT)            */
  792.     scsiDirectionIn                = 0x40000000,                    /* Data direction (01: DATA IN)                */
  793.     scsiDisableAutosense        = 0x20000000,                    /* Disable auto sense feature                */
  794.     scsiFlagReservedA            = 0x10000000,                    /*                                             */
  795.     scsiFlagReserved0            = 0x08000000,                    /*                                             */
  796.     scsiCDBLinked                = 0x04000000,                    /* The PB contains a linked CDB                */
  797.     scsiQEnable                    = 0x02000000,                    /* Target queue actions are enabled            */
  798.     scsiCDBIsPointer            = 0x01000000,                    /* The CDB field contains a pointer            */
  799.     scsiFlagReserved1            = 0x00800000,                    /*                                             */
  800.     scsiInitiateSyncData        = 0x00400000,                    /* Attempt Sync data xfer and SDTR            */
  801.     scsiDisableSyncData            = 0x00200000,                    /* Disable sync, go to async                */
  802.     scsiSIMQHead                = 0x00100000,                    /* Place PB at the head of SIM Q            */
  803.     scsiSIMQFreeze                = 0x00080000,                    /* Return the SIM Q to frozen state            */
  804.     scsiSIMQNoFreeze            = 0x00040000,                    /* Disallow SIM Q freezing                    */
  805.     scsiDoDisconnect            = 0x00020000,                    /* Definitely do disconnect                    */
  806.     scsiDontDisconnect            = 0x00010000,                    /* Definitely don't disconnect                */
  807.     scsiDataReadyForDMA            = 0x00008000,                    /* Data buffer(s) are ready for DMA            */
  808.     scsiFlagReserved3            = 0x00004000,                    /*  */
  809.     scsiDataPhysical            = 0x00002000,                    /* SG/Buffer data ptrs are physical            */
  810.     scsiSensePhysical            = 0x00001000,                    /* Autosense buffer ptr is physical            */
  811.     scsiFlagReserved5            = 0x00000800,                    /*                                          */
  812.     scsiFlagReserved6            = 0x00000400,                    /*                                             */
  813.     scsiFlagReserved7            = 0x00000200,                    /*                                             */
  814.     scsiFlagReserved8            = 0x00000100                    /*                                             */
  815. };
  816.  
  817. /* bit masks for the scsiIOFlags field in SCSIExecIOPB */
  818.  
  819. enum {
  820.     scsiNoParityCheck            = 0x0002,                        /* disable parity checking                             */
  821.     scsiDisableSelectWAtn        = 0x0004,                        /* disable select w/Atn                              */
  822.     scsiSavePtrOnDisconnect        = 0x0008,                        /* do SaveDataPointer upon Disconnect msg             */
  823.     scsiNoBucketIn                = 0x0010,                        /* don’t bit bucket in during this I/O                 */
  824.     scsiNoBucketOut                = 0x0020,                        /* don’t bit bucket out during this I/O             */
  825.     scsiDisableWide                = 0x0040,                        /* disable wide transfer negotiation                 */
  826.     scsiInitiateWide            = 0x0080,                        /* initiate wide transfer negotiation                 */
  827.     scsiRenegotiateSense        = 0x0100,                        /* renegotiate sync/wide before issuing autosense     */
  828.     scsiIOFlagReserved0080        = 0x0080,                        /*                                                  */
  829.     scsiIOFlagReserved8000        = 0x8000                        /*                                                     */
  830. };
  831.  
  832. /* Defines for the SIM/HBA queue actions.  These values are used in the */
  833.  
  834. /* SCSIExecIOPB, for the queue action field. [These values should match the */
  835.  
  836. /* defines from some other include file for the SCSI message phases.  We may */
  837.  
  838. /* not need these definitions here. ] */
  839.  
  840. enum {
  841.     scsiSimpleQTag                = 0x20,                            /* Tag for a simple queue                                 */
  842.     scsiHeadQTag                = 0x21,                            /* Tag for head of queue                                  */
  843.     scsiOrderedQTag                = 0x22                            /* Tag for ordered queue                                 */
  844. };
  845.  
  846. /* Defines for the Bus Inquiry PB fields. */
  847.  
  848. /* scsiHBAInquiry field bits */
  849.  
  850. enum {
  851.     scsiBusMDP                    = 0x80,                            /* Supports Modify Data Pointer message                        */
  852.     scsiBusWide32                = 0x40,                            /* Supports 32 bit wide SCSI                                */
  853.     scsiBusWide16                = 0x20,                            /* Supports 16 bit wide SCSI                                */
  854.     scsiBusSDTR                    = 0x10,                            /* Supports Sync Data Transfer Req message                    */
  855.     scsiBusLinkedCDB            = 0x08,                            /* Supports linked CDBs                                        */
  856.     scsiBusTagQ                    = 0x02,                            /* Supports tag queue message                                */
  857.     scsiBusSoftReset            = 0x01                            /* Supports soft reset                                        */
  858. };
  859.  
  860. /* scsiDataTypes field bits  */
  861.  
  862. /*    bits 0->15 Apple-defined, 16->30 3rd-party unique, 31 = reserved */
  863.  
  864. enum {
  865.     scsiBusDataTIB                = (1 << scsiDataTIB),            /* TIB supplied (ptr in scsiDataPtr)        */
  866.     scsiBusDataBuffer            = (1 << scsiDataBuffer),        /* single contiguous buffer supplied         */
  867.     scsiBusDataSG                = (1 << scsiDataSG),            /* scatter/gather list supplied             */
  868.     scsiBusDataReserved            = 0x80000000                    /*                                           */
  869. };
  870.  
  871. /* scsiScanFlags field bits */
  872.  
  873. enum {
  874.     scsiBusScansDevices            = 0x80,                            /* Bus scans for and maintains device list            */
  875.     scsiBusScansOnInit            = 0x40,                            /* Bus scans performed at power-up/reboot            */
  876.     scsiBusLoadsROMDrivers        = 0x20                            /* may load ROM drivers to support targets             */
  877. };
  878.  
  879. /* scsiFeatureFlags field bits */
  880.  
  881. enum {
  882.     scsiBusInternalExternalMask    = 0x000000C0,                    /* bus internal/external mask                    */
  883.     scsiBusInternalExternalUnknown = 0x00000000,                /* not known whether bus is inside or outside     */
  884.     scsiBusInternalExternal        = 0x000000C0,                    /* bus goes inside and outside the box             */
  885.     scsiBusInternal                = 0x00000080,                    /* bus goes inside the box                         */
  886.     scsiBusExternal                = 0x00000040,                    /* bus goes outside the box                     */
  887.     scsiBusCacheCoherentDMA        = 0x00000020,                    /* DMA is cache coherent                         */
  888.     scsiBusOldCallCapable        = 0x00000010,                    /* SIM is old call capable                         */
  889.     scsiBusDifferential            = 0x00000004,                    /* Single Ended (0) or Differential (1)         */
  890.     scsiBusFastSCSI                = 0x00000002,                    /* HBA supports fast SCSI                         */
  891.     scsiBusDMAavailable            = 0x00000001                    /* DMA is available                             */
  892. };
  893.  
  894. /* scsiWeirdStuff field bits */
  895.  
  896. enum {
  897.     scsiOddDisconnectUnsafeRead1 = 0x0001,                        /* Disconnects on odd byte boundries are unsafe with DMA and/or blind reads */
  898.     scsiOddDisconnectUnsafeWrite1 = 0x0002,                        /* Disconnects on odd byte boundries are unsafe with DMA and/or blind writes */
  899.     scsiBusErrorsUnsafe            = 0x0004,                        /* Non-handshaked delays or disconnects during blind transfers may cause a crash */
  900.     scsiRequiresHandshake        = 0x0008,                        /* Non-handshaked delays or disconnects during blind transfers may cause data corruption */
  901.     scsiTargetDrivenSDTRSafe    = 0x0010                        /* Targets which initiate synchronous negotiations are supported */
  902. };
  903.  
  904. /* scsiHBAslotType values */
  905.  
  906. enum {
  907.     scsiMotherboardBus            = 0x01,                            /* A built in Apple supplied bus                     */
  908.     scsiNuBus                    = 0x02,                            /* A SIM on a NuBus card                             */
  909.     scsiPDSBus                    = 0x03,                            /*    "  on a PDS card                                */
  910.     scsiPCIBus                    = 0x04,                            /*    "  on a PCI bus card                            */
  911.     scsiPCMCIABus                = 0x05,                            /*    "  on a PCMCIA card                            */
  912.     scsiFireWireBridgeBus        = 0x06                            /*    "  connected through a FireWire bridge        */
  913. };
  914.  
  915. /* Defines for the scsiDriverFlags field (in SCSIDriverPB) */
  916.  
  917. enum {
  918.     scsiDeviceSensitive            = 0x0001,                        /* Only driver should access this device                */
  919.     scsiDeviceNoOldCallAccess    = 0x0002                        /* no old call access to this device                     */
  920. };
  921.  
  922. /*  SIMInitInfo PB */
  923.  
  924. /* directions are for SCSIRegisterBus call ( -> parm, <- result)             */
  925.  
  926. #if defined(powerc) || defined (__powerc)
  927. #pragma options align=mac68k
  928. #endif
  929. struct SIMInitInfo {
  930.     unsigned char                            *SIMstaticPtr;                /* <- alloc. ptr to the SIM's static vars                 */
  931.     long                            staticSize;                    /* -> num bytes SIM needs for static vars                 */
  932.     SIMInitProc                        SIMInit;                    /* -> pointer to the SIM init routine                     */
  933.     SIMActionProc                    SIMAction;                    /* -> pointer to the SIM action routine                 */
  934.     SCSIProc                        SIM_ISR;                    /*       reserved                                             */
  935.     InterruptPollProc                SIMInterruptPoll;            /* -> pointer to the SIM interrupt poll routine            */
  936.     SIMActionProc                    NewOldCall;                    /* -> pointer to the SIM NewOldCall routine                */
  937.     unsigned short                            ioPBSize;                    /* -> size of SCSI_IO_PBs required for this SIM            */
  938.     Boolean                            oldCallCapable;                /* -> true if this SIM can handle old-API calls            */
  939.     unsigned char                            simInfoUnused1;                /*       reserved                                            */
  940.     long                            simInternalUse;                /* xx not affected or viewed by XPT                        */
  941.     SCSIProc                        XPT_ISR;                    /*    reserved                                            */
  942.     SCSIProc                        EnteringSIM;                /* <- ptr to the EnteringSIM routine                    */
  943.     SCSIProc                        ExitingSIM;                    /* <- ptr to the ExitingSIM routine                        */
  944.     MakeCallbackProc                MakeCallback;                /* <- pointer to the XPT layer’s MakeCallback routine    */
  945.     unsigned short                            busID;                        /* <- bus number for the registered bus                    */
  946.     unsigned short                            simInfoUnused3;                /* <- reserved                                            */
  947.     long                            simInfoUnused4;                /* <- reserved                                            */
  948. };
  949. #if defined(powerc) || defined(__powerc)
  950. #pragma options align=reset
  951. #endif
  952.  
  953. typedef struct SIMInitInfo SIMInitInfo;
  954.  
  955. /* Glue between SCSI calls and SCSITrap format */
  956.  
  957.  
  958. enum {
  959.     xptSCSIAction                = 0x0001,
  960.     xptSCSIRegisterBus            = 0x0002,
  961.     xptSCSIDeregisterBus        = 0x0003,
  962.     xptSCSIReregisterBus        = 0x0004,
  963.     xptSCSIKillXPT                = 0x0005                        /* kills Mini-XPT after transition */
  964. };
  965.  
  966. /* moveq #kSCSIx, D0;  _SCSIAtomic */
  967.  
  968.  
  969. #if USES68KINLINES
  970. #pragma parameter __D0 SCSIAction(__A0)
  971. #endif
  972. extern OSErr SCSIAction(SCSI_PB *)
  973.  TWOWORDINLINE(0x7001, _SCSIAtomic);
  974.  
  975. #if USES68KINLINES
  976. #pragma parameter __D0 SCSIRegisterBus(__A0)
  977. #endif
  978. extern OSErr SCSIRegisterBus(SIMInitInfo *)
  979.  TWOWORDINLINE(0x7002, _SCSIAtomic);
  980.  
  981. #if USES68KINLINES
  982. #pragma parameter __D0 SCSIDeregisterBus(__A0)
  983. #endif
  984. extern OSErr SCSIDeregisterBus(SCSI_PB *)
  985.  TWOWORDINLINE(0x7003, _SCSIAtomic);
  986.  
  987. #if USES68KINLINES
  988. #pragma parameter __D0 SCSIReregisterBus(__A0)
  989. #endif
  990. extern OSErr SCSIReregisterBus(SIMInitInfo *)
  991.  TWOWORDINLINE(0x7004, _SCSIAtomic);
  992.  
  993. #if USES68KINLINES
  994. #pragma parameter __D0 SCSIKillXPT(__A0)
  995. #endif
  996. extern OSErr SCSIKillXPT(SIMInitInfo *)
  997.  TWOWORDINLINE(0x7005, _SCSIAtomic);
  998.  
  999. #ifdef __cplusplus
  1000. }
  1001. #endif
  1002.  
  1003. #endif /* __SCSI__ */
  1004.